package cn.cqone.crm.controller;

import cn.cqone.crm.domain.Role;
import cn.cqone.crm.mapper.RoleMapper;
import cn.cqone.crm.query.RoleQuery;
import cn.cqone.crm.utils.JSONResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/role")
@CrossOrigin
@RequiresPermissions("role:main")
public class RoleController extends BaseController<Role,Long,RoleQuery>{

    @Autowired
    private RoleMapper roleMapper;

    @ResponseBody
    @RequestMapping(value = "/findRoleAll",method = RequestMethod.GET)
    public JSONResult findRoleAll(){
        try{
            List<Role> list = roleMapper.findRoleAll();
            return JSONResult.ok(list);
        }catch (Exception e){
            e.printStackTrace();
            return JSONResult.error("服务器异常,我们正在殴打程序员...");
        }
    }
}
